unit ScuolaMaternaAppControllerU;

interface

uses
  MVCFramework, MainDataModuleUnit, InterfaceU;

type

  [MVCPath('/')]
  TScuolaMaternaApp = class(TMVCController)
  {
  protected
    procedure OnBeforeAction(Context: TWebContext; const AActionNAme: string; var Handled: Boolean); override;
    procedure OnAfterAction(Context: TWebContext; const AActionNAme: string); override;
  }
  public
{
    [MVCPath('/')]
    [MVCHTTPMethod([httpGET])]
    procedure Index(ctx: TWebContext);
}
    [MVCPath('/getalunni/($periodo)')]
    [MVCHTTPMethod([httpGET])]
    procedure GetElencoAlunni(ctx: TWebContext);

    [MVCPath('/getalunnibyiniziale/($iniziale)')]
    [MVCHTTPMethod([httpGET])]
    procedure GetAlunniByIniziale(ctx: TWebContext);
{
    [MVCPath('/wines')]
    [MVCHTTPMethod([httpPOST])]
    procedure SaveWine(ctx: TWebContext);

    [MVCPath('/wines/search/($value)')]
    procedure FindWines(ctx: TWebContext);

    [MVCPath('/wines/($id)')]
    [MVCHTTPMethod([httpGET, httpDELETE])]
    procedure WineById(ctx: TWebContext);

    [MVCPath('/wines/($id)')]
    [MVCHTTPMethod([httpPUT])]
    procedure UpdateWineById(ctx: TWebContext);
}
  end;

implementation

uses
  ConnectionU;
  //Spring.Container, Spring.Services;

{ TScuolaMaternaApp }

procedure TScuolaMaternaApp.GetAlunniByIniziale(ctx: TWebContext);
begin
  render(TGestioniFactory.GestioneAlunni.GetAlunniByIniziale(ctx.Request.Params['iniziale']));
end;

procedure TScuolaMaternaApp.GetElencoAlunni(ctx: TWebContext);
//var
  //GestioneAlunni : IGestioneAlunni;
begin
//  GestioneAlunni := ServiceLocator.GetService<IGestioneAlunni>;
//  render(GestioneAlunni.GetElencoAlunni(ctx.Request.Params['periodo']));
  render(TGestioniFactory.GestioneAlunni.GetElencoAlunni(ctx.Request.Params['periodo']));
end;
{
procedure TScuolaMaternaApp.OnAfterAction(Context: TWebContext; const AActionNAme: string);
begin
  inherited;
  dm.Free;
end;

procedure TScuolaMaternaApp.OnBeforeAction(Context: TWebContext; const AActionNAme: string; var Handled: Boolean);
begin
  inherited;
  dm:= TScuolaMaternaDataModule.Create(nil);
end;
}
end.
